<template>
    <div class="app">
        <div>
            <button @click="isShow = !isShow">切换</button>
        </div>
        <transition name="why" mode="out-in" appear>
           <component :is="isShow? 'home':'about'"></component>
        </transition>

    </div>
</template>
<script setup>
import { ref } from "vue";
const isShow = ref(false)

</script>
<script>
import home from "@/03render的使用/home.vue";
import about from "./about.vue";
export default {
    components: {
        home,
        about
    }
}
</script>
<style scoped>
h2 {
    display: inline-block;
}

.v-enter-from,
.v-leave-to {
    opacity: 0;
    transform: scale(0.6);
}


.v-leave-from,
.v-enter-to {
    opacity: 1;
    transform: scale(1);
}

.v-enter-active,
.v-leave-active {
    transition: all 2s ease;
}

@keyframes whyani {
    0% {
        transform: scale(0);
        opacity: 0;
    }

    50% {
        transform: scale(1.2);
        opacity: 0.5;
    }

    100% {
        transform: scale(1);
        opacity: 1;
    }
}

@keyframes whylea {
    0% {
        transform: translateX(0);
        opacity: 1;
    }

    100% {
        transform: translateX(-500px);
        opacity: 0;
    }
}

.why-enter-active {
    animation: whyani 2s ease;
}

.why-leave-active {
    /* animation: whylea 2s ease; */
    animation: whyani 2s ease reverse;
}
</style>